x11: Avoid spurious focus events on grabs
authorBenjamin Otte <otte@redhat.com>
Mon, 19 Dec 2011 11:39:53 +0000 (12:39 +0100)
committerBenjamin Otte <otte@redhat.com>
Wed, 7 Mar 2012 14:35:21 +0000 (15:35 +0100)
We want to avoid handling focus events for the private focus window,
otherwise the keyboard grab taken by for example buttons will cause a
spurious FOCUS_OUT/FOCUS_IN on the toplevel.

The code that did this seems to have been lost in the XI2 transition for
GTK3.

This patch reapplies db4a6040afd3d1cabbb306037e811f37d62e2e76 which was
backed out in 18406b7b04da088f8a3efe7cca5ac1647080dc0b to give
developers a chance to get their X servers fixed. As we want to get this
bugfix in for 3.4, we need to commit it now.

https://bugzilla.gnome.org/show_bug.cgi?id=657578

gdk/x11/gdkdevicemanager-core-x11.c
gdk/x11/gdkdevicemanager-xi2.c
gdk/x11/gdkdevicemanagerprivate-core.h

index 90630de4321708ff64f99dbd32cceed363a3af22..38a225cafca90eeeed0e18aee44dc9169e8a365d 100644 (file)
@@ -663,6 +663,7 @@ gdk_x11_device_manager_core_translate_event (GdkEventTranslator *translator,
     case FocusOut:
       if (window)
         _gdk_device_manager_core_handle_focus (window,
+                                               xevent->xfocus.window,
                                                device_manager->core_keyboard,
                                                NULL,
                                                xevent->type == FocusIn,
@@ -794,6 +795,7 @@ _gdk_x11_event_translate_keyboard_string (GdkEventKey *event)
  */
 void
 _gdk_device_manager_core_handle_focus (GdkWindow *window,
+                                       Window     original,
                                        GdkDevice *device,
                                        GdkDevice *source_device,
                                        gboolean   focus_in,
@@ -818,6 +820,9 @@ _gdk_device_manager_core_handle_focus (GdkWindow *window,
   if (!toplevel)
     return;
 
+  if (toplevel->focus_window == original)
+    return;
+
   had_focus = HAS_FOCUS (toplevel);
 
   switch (detail)
index 6f93fd21b23af7dc271710076b71498fef033990..0b9dc19f71d0c7561aa8ae49b5e86bfd18771732 100644 (file)
@@ -1561,6 +1561,7 @@ gdk_x11_device_manager_xi2_translate_event (GdkEventTranslator *translator,
                                              GUINT_TO_POINTER (xev->sourceid));
 
         _gdk_device_manager_core_handle_focus (window,
+                                               xev->event,
                                                device,
                                                source_device,
                                                (ev->evtype == XI_FocusIn) ? TRUE : FALSE,
index 470a98a7d2752475081279c27b11b7baf62a9cec..4de19d1e8fda3614f89103795ff5f82786240403 100644 (file)
@@ -18,6 +18,8 @@
 #ifndef __GDK_DEVICE_MANAGER_PRIVATE_CORE_H__
 #define __GDK_DEVICE_MANAGER_PRIVATE_CORE_H__
 
+#include <X11/Xlib.h>
+
 #include "gdkx11devicemanager-core.h"
 #include "gdkdevicemanagerprivate.h"
 
@@ -36,6 +38,7 @@ struct _GdkX11DeviceManagerCoreClass
 };
 
 void            _gdk_device_manager_core_handle_focus           (GdkWindow   *window,
+                                                                 Window       original,
                                                                  GdkDevice   *device,
                                                                  GdkDevice   *source_device,
                                                                  gboolean     focus_in,